package gazzera.swing.download;

/* 
 * ColorRenderer.java (compiles with releases 1.2, 1.3, and 1.4) is used by 
 * TableDialogEditDemo.java.
 */

import gazzera.swing.model.*;

import java.awt.*;

import javax.swing.*;
import javax.swing.border.*;
import javax.swing.table.*;


public class DownloadNameRenderer  extends JLabel
                           implements TableCellRenderer {
    Border unselectedBorder = null;
    Border selectedBorder = null;
    boolean isBordered = true;

    public DownloadNameRenderer(boolean isBordered) {
        super();
    	this.isBordered = isBordered;
        setOpaque(true); //MUST do this for background to show up.
    }

    public Component getTableCellRendererComponent(
                            JTable table, Object o,
                            boolean isSelected, boolean hasFocus,
                            int row, int column) {
        
    	Download c = (Download)o;
 

    	String s = "<html>"+c.name+"<br><small style=\"color:#d0d0d0\">"+c.fileId+"</small></html>";
    	if(isSelected)
    	{
    		setBackground(table.getSelectionBackground());//new Color(0xb8,0xcf,0xe5));
    	}
    	else
    	{
    		setBackground(table.getBackground());
    	}
    	setForeground(isSelected ? Color.WHITE : Color.BLACK);
        setText(s);
        
        
        return this;
    }
}
